/*
 * lowpass_filter.h
 *
 *  Created on: 2021-09-27
 *      Author: chenss
 */

#ifndef INC_LOWPASS_FILTER_H_
#define INC_LOWPASS_FILTER_H_

#include "main.h"
#include "tick.h"

#define LOWPASS_FILTER_DEFAULT_TF 0.005

typedef struct
{
    float Tf; //!< Low pass filter time constant

    Tick_t timestamp_prev;  //!< Last execution timestamp
    float y_prev; //!< filtered value in previous execution step
}LowPassFilter_t;

void LowPassFilter_Init(LowPassFilter_t *lpf, float Tf);
float LowPassFilter_Operate(LowPassFilter_t *lpf, float x);

#endif /* INC_LOWPASS_FILTER_H_ */
